
var Ajax={
	SendAjax:function(action,params,callback){ 
		var fn="Ajax.SendAjax";
		try{
			if(typeof action=='undefined'||action==""||action==null)
			{
				return false;
			}
			var request = {
				action : action,
				content : params
			}
			var url = "http://58.48.168.50:2580/h5c/gsoap/service.php";
			
			if(window.location.host.indexOf('219.139.130.122')!==-1 || window.location.host.indexOf('yl.wgtd.cn')!==-1 || window.location.host.indexOf('localhost')!==-1){
				// url = "https://219.139.44.119:2580/h5c/gsoap/service.php"
				url = "https://ylydzf.wgtd.cn:7001/h5c/gsoap/service.php"
			}
			
			jQuery.ajax({
				type:"POST",
				// url : 'http://58.49.98.18:25580/h5c/gsoap/service.php',
				// http://58.49.98.18:25580/nmi  192.168.9.4:2580 
				url : url,
				dataType: "json",
				// data: encodeURIComponent(Object.toJSON(request)),
				data: encodeURIComponent(JSON.stringify(request)),
				success:function(rv){
					if(jQuery.isFunction(callback))
					{
						callback(rv);
					}
				},
				error:function(error){
					alert("Ajax发送失败"+error.message);
				}
			});
		}catch(e){
			console.log(fn+":发生异常，"+e.name+","+e.message)
		}
	},

	Construct:function(errorCode){
		switch(errorCode){
			case "0x0000" :
				$.messager.alert("操作提示","0x0000 成功","info",function(){});
				break;
			case "0X0001" :
				$.messager.alert("操作提示","0X0001 失败","error",function(){});
				break;
			case "0x0002" :
				$.messager.alert("操作提示","0x0002 抛出异常","error",function(){});
				break;
			case "0x0010" :
				$.messager.alert("操作提示","0x0010 系统已登录","error",function(){});
				break;
			case "0x0011" :
				$.messager.alert("操作提示","0x0011 系统未登录","error",function(){});
				break;
			case "0x0012" :
				$.messager.alert("操作提示","0x0012 超过最大连接数","error",function(){});
				break;
			case "0x0020" :
				$.messager.alert("操作提示","0x0020 请求Action出错 ","error",function(){});
				break;
			case "0x0021" :
				$.messager.alert("操作提示","0x0021 请求Action未知","error",function(){});
				break;
			case "0x0022" :
				$.messager.alert("操作提示","0x0022 请求Action不存在","error",function(){});
				break;
			case "0x0030" :
				$.messager.alert("操作提示","0x0030 请求content出错","error",function(){});
				break;
			case "0x0031" :
				$.messager.alert("操作提示","0x0031 请求content内容为空","error",function(){});
				break;
			case "0x0032" :
				$.messager.alert("操作提示","0x0032 请求content不存在","error",function(){});
				break;
			case "0x0033" :
				$.messager.alert("操作提示","0x0033 offset过大","error",function(){});
				break;
			case "0x0040" :
				$.messager.alert("操作提示","0x0040 参数不合法","error",function(){});
				break;
			case "0x0050" :
				$.messager.alert("操作提示","0x0050 MYSQL数据库连接实例对象失败","error",function(){});
				break;
			case "0x0051" :
				$.messager.alert("操作提示","0x0051 MYSQL数据库操作失败","error",function(){});
				break;
			case "0x0060" :
				$.messager.alert("操作提示","0x0060 WebService请求地址错误","error",function(){});
				break;
			case "0x0061" :
				$.messager.alert("操作提示","0x0061 WebService密码验证错误","error",function(){});
				break;
			case "0x0062" :
				$.messager.alert("操作提示","0x0062 WebService响应失败","error",function(){});
				break;
			case "0x0063" :
				$.messager.alert("操作提示","0x0063 WebService参数验证失败","error",function(){});
				break;
			case "0x0064" :
				$.messager.alert("操作提示","0x0064 WebService对象未实例化","error",function(){});
				break;
			case "0x1000" :
				$.messager.alert("操作提示","0x1000 登录失败","error",function(){});
				break;
			case "0x1001" :
				$.messager.alert("操作提示","0x1001 登录超时","error",function(){});
				break;
			case "0x1010" :
				$.messager.alert("操作提示","0x1010 登录用户名格式错误","error",function(){});
				break;
			case "0x1011" :
				$.messager.alert("操作提示","0x1011 登录用户名不存在","error",function(){});
				break;
			case "0x1012" :
				$.messager.alert("操作提示","0x1012 登录密码错误","error",function(){});
				break;
			case "0x1013" :
				$.messager.alert("操作提示","0x1013 登录用户名参数不合法","error",function(){});
				break;
			case "0x1014" :
				$.messager.alert("操作提示","0x1014 登录超过最大连接数","error",function(){});
				break;
			case "0x1020" :
				$.messager.alert("操作提示","0x1020 SESSION错误","error",function(){});
				break;
			case "0x1021" :
				$.messager.alert("操作提示","0x1021 SESSION失效","error",function(){});
				break;
			case "0x1022" :
				$.messager.alert("操作提示","0x1022 SESSION长度不合法","error",function(){});
				break;
			case "0x2000" :
				$.messager.alert("操作提示","0x2000 XML发送至远程服务器失败","error",function(){});
				break;
			case "0x2001" :
				$.messager.alert("操作提示","0x2001 XML报文解析失败","error",function(){});
				break;
			case "0x2002" :
				$.messager.alert("操作提示","0x2002 XML返回错误","error",function(){});
				break;
			case "0x2003" :
				$.messager.alert("操作提示","0x2003 XML发送OPTID错误","error",function(){});
				break;
			case "0x2004" :
				$.messager.alert("操作提示","0x2004 XML报文NU错误","error",function(){});
				break;
		}
	}
}

export default Ajax